
# install
install(TARGETS ${PROJECT_NAME} EXPORT EXPORT_TARGETS DESTINATION lib)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/include/ DESTINATION include)

# export
install(EXPORT EXPORT_TARGETS FILE ${PROJECT_NAME}Config.cmake DESTINATION share/cmake)
export(EXPORT EXPORT_TARGETS FILE ${PROJECT_NAME}Config.cmake)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
        "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
        VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
        COMPATIBILITY AnyNewerVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION share/cmake)

# package
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/License.txt)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_SOURCE_IGNORE_FILES build* cmake-build* .git .gitignore .idea)
set(CPACK_SOURCE_GENERATOR TGZ ZIP)
set(CPACK_GENERATOR TGZ)
include(CPack)